import java.util.Random;
import java.util.Scanner;

public class SehirTahmin {
    public static void main(String[] args) {
        int score=0;
        int error=0;
        boolean situation=true;
        Random rand=new Random();

        Scanner scanner = new Scanner(System.in);
        System.out.println("<<ŞEHİR TAHMİN OYUNUNA HOŞGELDİNİZ!!!>>");
        System.out.println("================================================");

        System.out.println("<<Kaç adet şehir ismi girmek istersiniz?>>");
        int length = scanner.nextInt();

        int a = 0;
        String[] cities = new String[length];

        while (a<length){
            System.out.println("<<Lütfen şehir isimlerini giriniz.>>");
            String cityName = scanner.next();
            cities[a]=(cityName);
            a++;
        }

        for (String city : cities) {
            System.out.println("- "+city);
        }

        System.out.println("Do you want to start the game (Y) or (N)?");
        String game = scanner.next().toLowerCase();

        switch (game) {
            case "y":
                while(situation) {
                    if (score==5 || error== 10){
                        situation = !situation;
                        System.out.println("Your score is " + score + " and your error is " + error + ".");
                        if (score==5) {
                            System.out.println("=======================================");
                            System.out.println("Congratulations you won!");
                            System.out.println("=======================================");
                        }
                        else System.out.println("Nice score! Try Again!");
                    }
                    else {
                        System.out.println("Please enter a city name for predictions");
                        String estimate = scanner.next();
                        int b =rand.nextInt(length);
                        if (cities[b].equals(estimate)){
                            score++;
                        }
                        else {
                            System.out.println("Your choice was: "+estimate+" but choiced city was: "+cities[b]);
                            error++;
                        }
                        System.out.println();
                        System.out.println("========================================================");
                        System.out.println("Your score is " + score + " and your error is " + error + ".");
                        System.out.println("========================================================");
                        System.out.println();
                    }
                }
            break;
            case "n":
                System.out.println("Have a good day and don't forget us!");
            break;
            default:
                System.out.println("Please enter valid answer!!!");
        }
    }
}
